/*
 * 
 */

package multiplieralgorithm;

/**
 *
 * @author Kylan Robinson (krobinso@eecs.wsu.edu)
 */
public class Cell {

    public char type;               //the cell type (A-H are valid values)
    public int opA;                 //the A input operand
    public int opB;                 //the B input operand
    public int opC;                 //the C input operand
    public int opD;                 //the D input operand
    public int m;                   //number of bits per cell

    public Cell() {
        type = 'X'; //default cell type is invalid
        opA = opB = opC = opD = 0;
        m = 0;
    }
    
    //set the cell type
    public void setType(char new_type) {
        type = new_type;        //valid types include A-H
    }
    
    public void setType(char new_type, int new_m) {
        type = new_type;
        m = new_m;
    }
    
    //set the A operand
    public void setA(int new_a) {
        opA = new_a;
    }
    
    //set the B operand
    public void setB(int new_b) {
        opB = new_b;
    }
    
    //set the C operand
    public void setC(int new_c) {
        opC = new_c;
    }
    
    //set the D operand
    public void setD(int new_d) {
        opD = new_d;
    }
    
        //set the A operand
    public void incA(int new_a) {
        opA += new_a;
    }
    
    //set the B operand
    public void incB(int new_b) {
        opB += new_b;
    }
    
    //set the C operand
    public void incC(int new_c) {
        opC += new_c;
    }
    
    //set the D operand
    public void incD(int new_d) {
        opD += new_d;
    }
    
    //set both operands
    public void setOperands(int new_a, int new_b, int new_c, int new_d) {
        setA(new_a);
        setB(new_b);
        setC(new_c);
        setD(new_d);
    }
        
    //print the cell type
    public void printType() {
        System.out.print(type);
    }
    
    //print the operands of the cell
    public void printOperands() {
        System.out.print(opA);
        System.out.print('/');
        System.out.print(opB);
        System.out.print('/');
        System.out.print(opC);
        System.out.print('/');
        System.out.print(opD);
    }
    
    //perform the correct multiplication, depending on cell type
    public int compute() {        
        return opA * opB + opC + opD;
    }

}
